package com.eduagent.xwqeduagent.controller;

import com.eduagent.xwqeduagent.common.BaseResponse;
import com.eduagent.xwqeduagent.common.ResultUtils;
import com.eduagent.xwqeduagent.model.dto.OJProgrammingAssistantRequest;
import com.eduagent.xwqeduagent.model.vo.OJProgrammingAssistantVO;
import com.eduagent.xwqeduagent.service.OJProgrammingAssistantService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import jakarta.annotation.Resource;

/**
 * OJ编程助手控制器
 */
@RestController
@RequestMapping("/oj-programming-assistant")
@Slf4j
public class OJProgrammingAssistantController {

    @Resource
    private OJProgrammingAssistantService ojProgrammingAssistantService;

    /**
     * 算法题目辅助解答
     *
     * @param request 编程助手请求
     * @return 助手回答结果
     */
    @PostMapping("/assist")
    public BaseResponse<OJProgrammingAssistantVO> getAssistance(@RequestBody OJProgrammingAssistantRequest request) {
        log.info("收到OJ编程助手请求: {}", request.getUserQuestion());

        OJProgrammingAssistantVO response = ojProgrammingAssistantService.provideAssistance(
                request.getProblemDetails(),
                request.getUserCode(),
                request.getUserQuestion(),
                request.getLanguage(),
                request.getSessionId()
        );

        return ResultUtils.success(response);
    }
} 